package com.elh.jvm.classpath;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;

import java.io.File;
import java.util.stream.Collector;
import java.util.stream.Collectors;

/**
 * 通配符*匹配
 *
 * @author liulei
 **/
public class WildcardEntry extends ZipEntry{


    public WildcardEntry(String path) {
        super(toPathList(path));
    }


    private static String toPathList(String path){
         path = path.replace("*", "");
        Collector<CharSequence, ?, String> joining = Collectors.joining(File.pathSeparator);
        return FileUtil.loopFiles(path).stream()
                .filter(e -> isJar(e.getName()))
                .map(e -> e.getAbsolutePath())
                .collect(Collectors.joining(File.pathSeparator));
    }
}
